package cn.gson.tj_springboot.model.pojos;

import javax.persistence.*;
import java.util.Objects;

@Entity
@Table(name = "function_", schema = "tjcrm", catalog = "")
public class Function {
    private int functionId;
    private String functionName;
    private String functionWay;
    private String functionIcon;
    private Role roleByRoleId;

    @Id
    @Column(name = "function_id", nullable = false)
    public int getFunctionId() {
        return functionId;
    }

    public void setFunctionId(int functionId) {
        this.functionId = functionId;
    }

    @Basic
    @Column(name = "function_name", nullable = true, length = 255)
    public String getFunctionName() {
        return functionName;
    }

    public void setFunctionName(String functionName) {
        this.functionName = functionName;
    }

    @Basic
    @Column(name = "function_way", nullable = true, length = 255)
    public String getFunctionWay() {
        return functionWay;
    }

    public void setFunctionWay(String functionWay) {
        this.functionWay = functionWay;
    }

    @Basic
    @Column(name = "function_icon", nullable = true, length = 255)
    public String getFunctionIcon() {
        return functionIcon;
    }

    public void setFunctionIcon(String functionIcon) {
        this.functionIcon = functionIcon;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Function function = (Function) o;
        return functionId == function.functionId &&
                Objects.equals(functionName, function.functionName) &&
                Objects.equals(functionWay, function.functionWay) &&
                Objects.equals(functionIcon, function.functionIcon);
    }

    @Override
    public int hashCode() {
        return Objects.hash(functionId, functionName, functionWay, functionIcon);
    }

    @ManyToOne
    @JoinColumn(name = "role_id", referencedColumnName = "role_id")
    public Role getRoleByRoleId() {
        return roleByRoleId;
    }

    public void setRoleByRoleId(Role roleByRoleId) {
        this.roleByRoleId = roleByRoleId;
    }
}
